<template>
	<view class="post-index-page page">
		<image :src="`${cloudStorage}index/top-bg.png`" mode="widthFix" class="top-bg"></image>
		<CustomNav :isBack="true" color="#000" :topBgColor="topBgColor" title="零工驿站"></CustomNav>
		<view class="list-block block" :style="'margin-top:'+mt">
			<template v-if="list.length>0">
				<view @click="navigate('/page_other/post/detail?id='+item.id)" class="item" v-for="item in list" :key="item.id">
					<view class="title">{{item.title}}</view>
					<view class="address"><view class="iconfont icon-dingwei"></view><view class="text">{{item.address||'暂无位置信息'}}</view></view>
				</view>
			</template>
			<view class="empty" v-else>暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {getPostList} from '@/api/post.js'
	export default{
		data(){
			return{
				topBgColor: 'rgba(0,0,0,0)',
				list:[],
			}
		},
		methods:{
			getList(){
				uni.showLoading({
					title:'加载中',
					mask:true
				})
				getPostList({}).then(res=>{
					this.list=res;
				})
			}
		},
		onLoad() {
			this.getList()
		}
	}
</script>

<style lang="scss" scoped>
	.post-index-page{
		overflow: hidden;
		.top-bg {
			position: absolute;
			z-index: -1;
			width: 100%;
		}
		
		.block {
			width: $content-width;
			margin: 0 auto;
			.item{
				width: 100%;
				background: #fff;
				border-radius: 8px;
				box-shadow: 0 0 0 0 #efefef;
				margin-bottom: 30rpx;
				padding: 30rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				height: 160rpx;
				.address{
					display: flex;
					align-items: center;
					.iconfont{
						color: #999;
					}
					.text{
						font-size: 28rpx;
						color: #999;
						overflow: hidden;
						text-overflow:ellipsis;
						white-space: nowrap;
					}
				}
			}
		}
	}
</style>